package javaapplication1.control;

import javaapplication1.service.PetOwnerService;
import javaapplication1.service.PetStoreService;
import javaapplication1.service.serviceImpl.PetOwnerServiceImpl;
import javaapplication1.service.serviceImpl.PetStoreServiceImpl;
import javaapplication1.view.LoginView;
import javaapplication1.view.MenuView;
import javaapplication1.view.SessionScope;

public class LoginControl {

	private PetOwnerService perOwnerService = new PetOwnerServiceImpl();
	private PetStoreService perStoreService = new PetStoreServiceImpl();

	public void loginControl(int choose, String username, String password) {
		if (username != null && username != "" && password != null
				&& password != "") {
			if (choose == 1) {
				this.perOwnerService.login(username, password);
			} else if (choose == 2) {
				this.perStoreService.login(username, password);
			}
		} else {
			System.out.println("输入为空，请重新输入");
			LoginView.login();
		}
		if (SessionScope.getUsername() == null
				|| SessionScope.getUsername() == "") {
			System.out.println("登陆失败，请重新登录");
			LoginView.login();
		} else {
			System.out.println("登陆成功");
			MenuView.menu();
		}
	}

}